package com.blog.study.study6;

import java.util.function.Predicate;

/**
 * 测试谓词.
 *
 * @author 张俊强~.
 * @date 2017/11/29-16:32.
 */
public class TestPredicates {

    public static void main(String[] args) {
        int num=100;

        Predicate<Integer> p1=(Integer i)-> i>0;

        boolean flag= p1.test(num);
        //判断是否大于0
        System.out.println(flag);

        //判断是否大于0并且小于10
        Predicate<Integer> p2=(Integer i)-> i<10;

        boolean flag2=p1.and(p2).test(num);
        System.out.println(flag2);

        //判断是否大于0并且小于10 或者是偶数
        Predicate<Integer> p3=(Integer i)->i%2==0;
        boolean flag3=(p1.and(p2)).or(p3).test(num);
        System.out.println(flag3);

        //判断是否相等
        Predicate<Integer> p4=Predicate.isEqual(100);
        boolean flag5=p4.test(num);
        System.out.println(flag5);
    }
}
